package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 *菜品套餐关联Mapper
 */
@Mapper
public interface SetmealDishMapper {

    /**
     * 根据菜品id查询套餐id
     * @param ids
     * @return
     */
    //sql:select setmeal_id from setmeal_dish where dish_id in (?,?,?)
    List<Long> getSetmealIdsByDishId(List<Long> ids);

    /**
     * 批量插入套餐菜品关系--动态sql
     * @param setmealDishes
     */
    //sql:insert into setmeal_dish(setmeal_id,dish_id,copies) values(?,?,?),(?,?,?),(?,?,?)
    void insertBatch(List<SetmealDish> setmealDishes);

    /**
     * 根据套餐id删除套餐菜品关系
     * 多条数据，一个套餐Id删除
     *
     * @param id
     */
    //sql:delete from setmeal_dish where setmeal_id
    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void deleteBySetmealId(Long id);

    /**
     * 根据套餐id查询套餐菜品关系
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getSetmealDishesBySetmealId(Long id);


    /**
     * 根据套餐id（多个）批量删除套餐菜品关系
     * @param ids
     */
    //sql:delete from setmeal_dish where setmeal_id in (?,?,?)
    void deleteBySetmealIds(List<Long> ids);
}
